package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Mobile   string `gorm:"type:varchar(30)"`
	Password string `gorm:"type:varchar(32)"`
}

func (u *User) FindUserByMobile(db *gorm.DB, mobile string) error {
	return db.Debug().Where("mobile=?", mobile).FirstOrCreate(u).Error
}

func (u *User) UserById(db *gorm.DB, id int64) error {
	return db.Debug().Where("id=?", id).First(u).Error
}
